package com.yuelao.yuelao_backend.config;

import io.minio.MinioClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * MinIO配置类
 */
@Configuration
@ConfigurationProperties(prefix = "minio")
@Data
public class MinioConfig {

    /**
     * MinIO服务地址
     */
    private String endpoint;

    /**
     * MinIO访问密钥
     */
    private String accessKey;

    /**
     * MinIO密钥
     */
    private String secretKey;

    /**
     * MinIO默认存储桶名称
     */
    private String bucketName;

    /**
     * 文件访问URL前缀
     */
    private String fileUrlPrefix;

    @Bean
    public MinioClient minioClient() {
        return MinioClient.builder()
                .endpoint(endpoint)
                .credentials(accessKey, secretKey)
                .build();
    }
}